<?php
require_once 'PHPUnit/Framework.php';
require_once 'OBoard/Page.php';
require_once 'OBoard/Finder.php';

class MockPageFinder extends PageFinder{
	function __construct($boardKind){}
	function getByNumber($num) {
		$page = new Page();
		$page->num = $num;
		$page->title = 'title';
		return $page;
	}
	function getListByPeriod($startDate, $endDate, $count = 20) {
		$page_list = array ();
		foreach (range(0, $count -1) as $num) {
			$page = new Page();
			$page->id = $page->num = $num;
			$page_list[] = $page;
		}
		return $page_list;
	}
}
class PageTest extends PHPUnit_Framework_TestCase {
	function setUp() {
		$this->page_finder = new MockPageFinder('board kind');
	}
	function testGetOnePageByNumber() {
		$page_finder = $this->page_finder;
		$page = $page_finder->getByNumber(1);
		$this->assertEquals('title', $page->title);
		$this->assertEquals('', $page->content);
	}
	function testPageListByPeriod() {
		$page_finder = $this->page_finder;
		$start = $end = '';
		foreach (range(10, 20) as $count) {
			$page_list = $page_finder->getListByPeriod($start, $end, $count);
			$this->assertEquals($count, sizeof($page_list));
		}
	}
	function testSetData(){
		$page = new Page();

		$page->setData(array('title'=>'Title1','content'=>'Content2'));
		$this->assertEquals('Title1',$page->title);
		$this->assertEquals('Content2',$page->content);

	}
}
?>
